package com.ctrip.cap.internal.appium.test;

import com.ctrip.cap.AppiumContext;
import com.ctrip.cap.device.Device;
import com.ctrip.cap.device.DeviceStoreFactory;
import com.ctrip.cap.device.exceptions.DeviceNotFoundException;
import com.ctrip.cap.internal.domain.Context;
import com.ctrip.cap.internal.test.MethodFilter;

public class PrepareDevice implements MethodFilter {

	@Override
	public void doFilter(Context context2) {
		AppiumContext context = (AppiumContext) context2;
		Device device = null;
		try {
			device = DeviceStoreFactory.getDeviceStore().take();
		} catch (InterruptedException e) {
			throw new DeviceNotFoundException("", e);
		}
		context.setDevice(device);
	}

}
